<template>
  <div id="app">
    <TitleVue v-if="titleShow"></TitleVue>
    <FanHuiVue v-if="fanhuiShow"></FanHuiVue>
    <router-view></router-view>
    <!-- 导航栏 -->
    <Nav v-if="NavShow"></Nav>
  </div>
</template>

<script>
import Nav from "@/components/Nav.vue";
import TitleVue from "@/components/Title.vue";
import FanHuiVue from "./components/FanHui.vue";
import axios from "axios";

export default {
  name: "App",
  data() {
    return {
      // routerName中组件不显示底部
      routerName: [
        "/log",
        "/my",
        "/register",
        "/chat",
        "/contentdetails",
        "/dianshitaineirong",
        "/homecontent",
      ],
      // titleShowName中组件不显示标题
      titleShowName: [
        "/log",
        "/my",
        "/register",
        "/chat",
        "/contentdetails",
        "/dianshitaineirong",
        "/homecontent",
      ],
      // fanhuiShowName中组件显示返回条
      fanhuiShowName: [
        "/my",
        "/register",
        "/contentdetails",
        "/dianshitaineirong",
        "/homecontent",
      ],
    };
  },
  computed: {
    NavShow() {
      // routerName的地址都不显示导航栏
      let pd = true;
      this.routerName.forEach((item) => {
        if (this.$route.path == item) {
          pd = false;
          return;
        }
      });
      return pd;
    },
    titleShow() {
      // titleShowName的地址都不显示导航栏
      let pd = true;
      this.titleShowName.forEach((item) => {
        if (this.$route.path == item) {
          pd = false;
          return;
        }
      });
      return pd;
    },
    fanhuiShow() {
      // titleShowName的地址才显示返回条
      let pd = false;
      this.fanhuiShowName.forEach((item) => {
        if (this.$route.path == item) {
          pd = true;
          return;
        }
      });
      return pd;
    },
  },
  mounted() {
    axios
      .post(
        "http://localhost:8080/user/uid",
        {
          uid: localStorage.getItem("userxx"),
        },
        {
          headers: {
            "Content-Type": "application/x-www-form-urlencoded", // 或者 'multipart/form-data'
          },
        }
      )
      .then((res) => {
        this.$store.state.userData = res.data.data;
      });
  },
  components: {
    Nav,
    TitleVue,
    FanHuiVue,
  },
};
</script>

<style>
</style>
